/*
 * InternalFrameDelegate.h  0.4.0 / Nov 30, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
#ifndef INTERNALFRAMEDELEGATE_H
#define INTERNALFRAMEDELEGATE_H

#include "Cute4jSwing.h"

#include "WindowDelegate.h"

// InternalFrameDelegate Class. ------------------------------------------------

/*!
 * \brief InternalFrame Delegate.
 *
 * \author Slobodan Vrkacevic
 * \version 0.4.0
 */
class CUTE4J_EXPORT InternalFrameDelegate : public WindowDelegate
{
protected:
  InternalFrameDelegate(JNIEnv *env, jobject obj);
public slots: // native calls
  void insertChild(JNIEnv *env, jlong childDelegate, jint index);
public: // native calls
  static void initialize(JNIEnv *env, jclass cls);
  static jlong newInstance(JNIEnv *env, jobject obj);
public:
  virtual void setFocusable(JNIEnv *env, jboolean focusable);
  virtual void requestFocus(JNIEnv *env);
  virtual jobject getBackground(JNIEnv *env, jclass colorClass);
  virtual void setBackground(JNIEnv *env, jint argb);
  virtual void setNullBackground(JNIEnv *env);
  virtual jobject getForeground(JNIEnv *env, jclass colorClass);
  virtual void setForeground(JNIEnv *env, jint argb);
  virtual void setNullForeground(JNIEnv *env);
  virtual jobject getFont(JNIEnv *env, jclass fontClass);
  virtual void setFont(JNIEnv *env, jobject font);
  virtual jint getCursor(JNIEnv *env);
  virtual void setCursor(JNIEnv *env, jint type);
  virtual void setComponentOrientation(JNIEnv *env, jint orientation);
  virtual void setToolTipText(JNIEnv *env, jstring text);
  virtual void setStatusTipText(JNIEnv *env, jstring text);
  virtual void setWhatsThisText(JNIEnv *env, jstring text);
public: // native callbacks
  QSize getLayoutPreferredSize();
public:
  inline QMdiSubWindow *qMdiSubWindow() const;
  inline QWidget *qMdiSubWidget() const;
protected:
  virtual bool eventFilter(QObject *obj, QEvent *e);
  virtual void filterEnabledEvents();
  virtual QWidget *paintingWidget();
  friend class DesktopPaneDelegate; // uses jniObject() function member
private:
  QWidget *m_internalWidget;
private:
  static jmethodID sm_getLayoutPreferredSizeMID;
};

// InternalFrameDelegate :: Public Inline Member Functions. --------------------

/*!
 * \brief Returns QMdiSubWindow adaptee.
 *
 * \return QMdiSubWindow adaptee
 */
inline QMdiSubWindow *InternalFrameDelegate::qMdiSubWindow() const
{
  return static_cast<QMdiSubWindow *>(qObject());
}

/*!
 * \brief Returns internal sub widget.
 *
 * \return internal sub widget
 */
inline QWidget *InternalFrameDelegate::qMdiSubWidget() const
{
  return m_internalWidget;
}

// Macro Definitions. ----------------------------------------------------------

#define INTERNAL_FRAME_CAST(delegate) \
    (reinterpret_cast<InternalFrameDelegate *>(delegate))
#define INTERNAL_FRAME_DELEGATE INTERNAL_FRAME_CAST(delegate)

#endif // INTERNALFRAMEDELEGATE_H
